<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>会员登录 - <?php echo config('website.site_name')?></title>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="__LIBS__/layui/css/layui.css">
    <link rel="stylesheet" href="__USER__/login/css/base.css">
    <link rel="stylesheet" href="__USER__/login/css/iconfont.css">
    <link rel="stylesheet" href="__USER__/login/css/reg.css">
</head>
<body>
<div id="ajax-hook"></div>
<div class="wrap">
    <div class="wpn">
        <div class="form-data pos">
            <a href=""><img src="__USER__/login/img/logo.png" class="head-logo"></a>
            <div class="change-login">
                <p class="account_number on">账号登录</p>
                <!--p class="message">短信登录</p-->
            </div>
            <form class="layui-form" id="loginForm" action="{:url('user/index/login')}" method="post">
                <div class="form1">
                    <p class="p-input pos">
                        <label for="num">手机号/用户名</label>
                        <input type="text" name="username" id="username" lay-verify="required" autocomplete="off" class="layui-input">
                        <span class="tel-warn num-err hide"><em>账号或密码错误，请重新输入</em><i class="icon-warn"></i></span>
                    </p>
                    <p class="p-input pos">
                        <label for="pass">请输入密码</label>
                        <input type="password" name="password" id="password" lay-verify="required" autocomplete="off" class="layui-input">
                        <span class="tel-warn pass-err hide"><em>账号或密码错误，请重新输入</em><i class="icon-warn"></i></span>
                    </p>
                    <!--p class="p-input pos code">
                        <label for="veri">请输入验证码</label>
                        <input type="text" name="captcha" lay-verify="required" autocomplete="off" class="layui-input">
                        <img class="verifyImg" src="{:url('user/index/captcha')}" onclick="this.src='{:url('user/index/captcha')}?rand='+Math.random()" />
                        <span class="tel-warn img-err hide"><em>账号或密码错误，请重新输入</em><i class="icon-warn"></i></span>
                        <!-- <a href="javascript:;">换一换</a>>
                    </p-->
                    <p class="p-input pos">
                        <input type="checkbox" id="remember" checked title="记住密码"  lay-skin="primary">
                    </p>
                </div>
                <!--div class="form2 hide">
                    <p class="p-input pos">
                        <label for="num2">手机号</label>
                        <input type="number" id="num2">
                        <span class="tel-warn num2-err hide"><em>账号或密码错误</em><i class="icon-warn"></i></span>
                    </p>
                    <p class="p-input pos">
                        <label for="veri-code">输入验证码</label>
                        <input type="number" id="veri-code">
                        <a href="javascript:;" class="send">发送验证码</a>
                        <span class="time hide"><em>120</em>s</span>
                        <span class="tel-warn error hide">验证码错误</span>
                    </p>
                </div-->
                <div class="r-forget cl">
                    <a href="/user/index/register" class="z">账号注册</a>
                    <a href="#" class="y">忘记密码</a>
                </div>
                <button class="lang-btn off log-btn" lay-submit lay-filter="login">登录</button>
            </form>
            <div class="third-party">
                <a href="#" class="log-qq icon-qq-round"></a>
                <a href="#" class="log-qq icon-weixin"></a>
                <a href="#" class="log-qq icon-sina1"></a>
            </div>
            <p class="right">Powered by <?php echo config('website.site_copyright')?> © 2018</p>
        </div>
    </div>
</div>
<script src="__USER__/login/js/jquery.js"></script>
<script src="__USER__/login/js/agree.js"></script>
<script src="__USER__/login/js/login.js"></script>
<script src="__LIBS__/layui/layui.js"></script>
<script>
    layui.use(['layer', 'form', 'jquery'], function(){
        var layer = layui.layer,
            form  = layui.form,
            $     = layui.jquery;
        form.on('submit(login)', function(data) {
            var index = layer.msg('登录中，请稍候', {
                icon: 16,
                time: false,
                shade: 0.3
            });
            $.ajax({
                url: data.form.action,
                type: data.form.method,
                dataType: 'json',
                data: $(data.form).serialize(),
                success: function(result) {
                    if (result.code === 1) {
                        location.href = result.url;
                    } else {
                        $('.captcha img').attr('src', '{:url("user/index/captcha")}?rand='+Math.random());
                        layer.close(index);
                        layer.msg(result.msg);
                    }
                },
                error: function (xhr, state, errorThrown) {
                    layer.close(index);
                    layer.msg(state + '：' + errorThrown);
                }
            });
            return false;
        });
    });
</script>
<script>
    $(function () {
        $('#loginForm').myForm(function (ret) {
            var isCkd = $('#remember').prop('checked');
            if (isCkd) {
                // 将用户名密码保存起来
                var erpLogin = {
                    username: $('#username').val(),
                    password: $('#password').val()
                };
                window.localStorage.setItem('erpLogin', JSON.stringify(erpLogin))
            }
            // 跳转
            window.location.href = ret.url;
        });
        // 自动填空
        var erpLogin = window.localStorage.getItem('erpLogin');
        if (erpLogin) {
            erpLogin = JSON.parse(erpLogin);
            $('#username').val(erpLogin.username);
            $('#password').val(erpLogin.password);
            $('#remember').prop('checked', true);
//            $('#loginForm').submit();
        }
    });

</script>
</body>
</html>

